{% extends 'base_tabler.html' %} {% load widget_tweaks %} {% block content %}
<div class="container mt-5">
  <div class="row justify-content-center">
    <div class="card" style="width: 450px">
      <div class="card-body p-4">
        <h2 class="card-title text-center mb-4">登录</h2>
        {% if form.errors %}
        <div class="alert alert-danger">
          <div class="d-flex">
            <div>
              <svg
                xmlns="http://www.w3.org/2000/svg"
                class="icon alert-icon"
                width="24"
                height="24"
                viewBox="0 0 24 24"
                stroke-width="2"
                stroke="currentColor"
                fill="none"
                stroke-linecap="round"
                stroke-linejoin="round"
              >
                <path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
                <path d="M12 9v4"></path>
                <path d="M12 17h.01"></path>
                <path d="M12 3c7.2 0 9 1.8 9 9s-1.8 9 -9 9s-9 -1.8 -9 -9s1.8 -9 9 -9z"></path>
              </svg>
            </div>
            <div>
              {% for field, errors in form.errors.items %} {% for error in errors %}
              <div>{{ error }}</div>
              {% endfor %} {% endfor %}
            </div>
          </div>
        </div>
        {% endif %}
        <form method="post">
          {% csrf_token %}
          <div class="mb-3">
            <label class="form-label">用户名</label>
            {{ form.username|add_class:"form-control" }} {% if form.username.errors %}
            <div class="invalid-feedback d-block">{% for error in form.username.errors %} {{ error }} {% endfor %}</div>
            {% endif %}
          </div>
          <div class="mb-3">
            <label class="form-label">密码</label>
            {{ form.password|add_class:"form-control" }} {% if form.password.errors %}
            <div class="invalid-feedback d-block">{% for error in form.password.errors %} {{ error }} {% endfor %}</div>
            {% endif %}
          </div>
          <div class="d-grid">
            <button type="submit" class="btn btn-primary">登录</button>
          </div>
        </form>
        <div class="text-center text-muted mt-3">还没有账号？<a href="{% url 'signup' %}">注册</a></div>
      </div>
    </div>
  </div>
</div>
{% endblock %}
